package com.shopping.dao.Impl;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.shopping.model.Admins;
@Repository
public interface IAdminsDao {

	/**
	 * 登录
	 * @param username
	 * @param password
	 * @return
	 */
    @Select("select*from admins where username=#{username} and password=#{password}") 
    Admins login(@Param("username")String username,@Param("password")String password);
    
    /**
     * 分页查询管理员信息
     */
    @Select("select count(*) from admins")
    Integer adminCount();
    @Select("select*from admins limit #{offset},#{pageSize}")
    List<Admins> findAdmins(@Param("offset")Integer offset,@Param("pageSize")Integer pageSize);
    
    /**
     * 添加管理员
     */
    @Insert("insert into admins values(null,#{username},#{password})")
    Integer insertAdmin(Admins admin);
    
    /**
     * 删除管理员
     */
    @Delete("DELETE FROM admins WHERE id=#{id};")
    Integer delAdmin(Integer id);
    
    /**
     * 重置管理员密码
     */
    //根据ID查询
    @Select("select*from admins where id=#{id}")
    Admins selByIdAdmin(Integer id); 
    
    @Update("update admins set password=#{password} where id=#{id}")
    Integer redAdmin(@Param("password")String password,@Param("id")Integer id);
    
}
